<?php

/**
 * 文件分类模型
 */

namespace app\common\model;

use think\model\concern\SoftDelete;
use tools\Tree;

class AttachmentCate extends Model
{
    // 自定义选择数据


    use SoftDelete;
    public $softDelete = true;
    protected $name = 'attachment_cate';
    protected $autoWriteTimestamp = true;

    //可搜索字段
    protected $searchField = [];

    //可作为条件的字段
    protected $whereField = [];

    //可做为时间
    protected $timeField = [];
    //获取分类树结构
    public static function getTreeCate()
    {
        $data = self::order(['sort'=>'desc'])->field(['id','name'=>'title','parent_id','level'])->select()->toArray();
        $info = (new Tree())->init($data)->getTreeArray(0);
        return $info;
    }
}
